package com.tangshuai.video.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tangshuai.video.mapper.VideoViewMapper;
import com.tangshuai.video.po.VideoView;
import com.tangshuai.video.service.VideoViewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author TANGSHUAI
 * @Date 2024-03-03 23:48
 **/
@Service
public class VideoViewServiceImpl implements VideoViewService {

    @Autowired
    private VideoViewMapper videoViewMapper;

    @Override
    public List<VideoView> selectByVideoInfoId(VideoView videoView) {
        LambdaQueryWrapper<VideoView> queryWrapper=new LambdaQueryWrapper<>();
        if(null!=videoView.getVideoInfoId()){
            queryWrapper.eq(VideoView::getVideoInfoId,videoView.getVideoInfoId());
        }
        if(null!=videoView.getId()){
            queryWrapper.eq(VideoView::getId,videoView.getId());
        }
        return videoViewMapper.selectList(queryWrapper);
    }

    @Override
    public VideoView selectById(Integer id) {
        return videoViewMapper.selectById(id);
    }

    @Override
    public Integer addVideoView(VideoView videoView) {
        return videoViewMapper.insert(videoView);
    }
}
